home *** CD-ROM | disk | FTP | other *** search
Wrap
// TDialog.cpp : implementation file // #include <afxwin.h> #include "stdafx.h" #include "InsTool.h" #include "InsSymb.h" #include "ViewWnd.h" #include "TDialog.h" #include "TDialog1.h" #include "Dirdialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /* const IID LIBID_IMSIGXLib = {0x6A481400,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}}; const IID IID_PickResult = {0x6A481123,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}}; //const IID IID_Tool = {0x6A48112C,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}}; const IID IID_Graphics = {0x6A48110A, 0xE531, 0x11CF, {0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}}; const IID IID_View = {0x6A481110, 0xE531, 0x11CF, {0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}}; const IID IID_Window = {0x6A481124, 0xE531, 0x11CF, {0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF} }; const CLSID CLSID_Application = {0x6A481001,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}}; const CLSID CLSID_XGraphic = {0x6A481803,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}}; static const IID IID_IAppEvents = { 0x6A481301, 0xE531, 0x11CF, { 0xA1, 0x15, 0x0, 0xA0, 0x24, 0x15, 0x8D, 0xAF } }; */ ///////////////////////////////////////////////////////////////////////////// BEGIN_MESSAGE_MAP(CTDialog, CDialog) //{{AFX_MSG_MAP(CTDialog) ON_BN_CLICKED(ID_CLOSE, OnClose) ON_BN_CLICKED(IDC_BROWSE, OnBrowse) ON_BN_CLICKED(IDC_MODIFY, OnModify) ON_BN_CLICKED(IDC_CHECK1, OnCheck1) ON_WM_SYSCOMMAND() //}}AFX_MSG_MAP END_MESSAGE_MAP() BEGIN_DISPATCH_MAP(CTDialog, CDialog) //{{AFX_DISPATCH_MAP(CTDialog) // NOTE - the ClassWizard will add and remove mapping macros here. DISP_FUNCTION(CTDialog, "MouseDown", MouseDown, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH VTS_DISPATCH VTS_I2 VTS_I4 VTS_I4 VTS_I4 VTS_PBOOL) DISP_FUNCTION(CTDialog, "MouseUp", MouseUp, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH VTS_DISPATCH VTS_I2 VTS_I4 VTS_I4 VTS_I4 VTS_PBOOL) DISP_FUNCTION(CTDialog, "MouseMove", MouseMove, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH VTS_DISPATCH VTS_I4 VTS_I4 VTS_I4 VTS_PBOOL) // DISP_FUNCTION(CTDialog, "DrawingBeforeClose", DrawingBeforeClose, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH VTS_DISPATCH VTS_I4 VTS_I4 VTS_I4 VTS_PBOOL) DISP_FUNCTION(CTDialog, "DrawingBeforeClose", DrawingBeforeClose, VT_EMPTY, VTS_DISPATCH VTS_PBOOL) //}}AFX_DISPATCH_MAP END_DISPATCH_MAP() // Note: we add support for IID_ITDialog to support typesafe binding // from VBA. This IID must match the GUID that is attached to the // dispinterface in the .ODL file. // {0416A816-839B-11D2-82F6-006052012837} ///static const IID IID_ITDialog = ///{ 0x416a816, 0x839b, 0x11d2, { 0x82, 0xf6, 0x0, 0x60, 0x52, 0x1, 0x28, 0x37 } }; BEGIN_INTERFACE_MAP(CTDialog, CDialog) INTERFACE_PART(CTDialog, IID_IAppEvents, Dispatch) END_INTERFACE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTDialog dialog CTDialog::CTDialog(CInsSymb* pTool, CWnd* pParent, /*=NULL*/Tool *pThisTool) : CDialog(CTDialog::IDD, pParent), m_dwEventConnection(0), m_dwEventMask(~0UL), m_pIApplication(NULL), m_FirstClick(FALSE), m_bDragging(FALSE), m_pDragGraphic(NULL), m_pView(NULL), m_pThisTool(NULL), m_wndView(pTool) { EnableAutomation(); //{{AFX_DATA_INIT(CTDialog) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pTool = pTool; m_pTool->AddRef(); m_pTool->m_bRunned = TRUE; m_pThisTool = pThisTool; m_pThisTool->AddRef(); } /* void CTDialog::OnFinalRelease() { // When the last reference for an automation object is released // OnFinalRelease is called. The base class will automatically // deletes the object. Add additional cleanup required for your // object before calling the base class. CDialog::OnFinalRelease(); } */ void CTDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CTDialog) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // CTDialog message handlers BOOL CTDialog::OnInitDialog() { BSTR bstrName; CString cstrPropName; CString cstrInitPath; COleVariant varItem; COleVariant varVal; Properties *pProps = NULL; Property *pProp = NULL; HRESULT hRes = E_FAIL; BOOL ret = FALSE; CDialog::OnInitDialog(); m_list.SubclassDlgItem( IDC_LIST1 , this ); CToolList *pList = (CToolList *)GetDlgItem(IDC_LIST1); try { /* hRes = m_pThisTool->get_Application(&m_pIApplication); CHECK_HRESULT(hRes) hRes = m_pIApplication->get_Properties(&pProps); CHECK_HRESULT(hRes) cstrPropName = "$SYMLIBPATH"; bstrName = cstrPropName.AllocSysString(); ::VariantInit(&varItem); varItem.vt = VT_BSTR; varItem.bstrVal = bstrName; hRes =pProps->get_Item (&varItem, &pProp); CHECK_HRESULT(hRes); varVal.vt = VT_BSTR; hRes = pProp->get_Value (NULL, &varVal); CHECK_HRESULT(hRes); cstrInitPath = varVal.bstrVal; if (cstrInitPath.IsEmpty ()) { cstrInitPath = "c\\"; } */ HMODULE hHdl = NULL; char path[256]; DWORD dBufSize = 256; DWORD dW = 0; hHdl = GetModuleHandle(NULL); dW = GetModuleFileName(hHdl, path, dBufSize); hHdl = NULL; cstrInitPath = path; cstrInitPath = cstrInitPath.Left(cstrInitPath.GetLength () - 10); // delete module name from path // cstrInitPath = "c:\\"; pList->RefreshFileList(cstrInitPath); CEdit *pPath = (CEdit *) GetDlgItem(IDC_EDITPATH); pPath->SetWindowText(cstrInitPath); CString selected; m_wndView.SubclassDlgItem(IDC_PREVIEW, this); CViewWnd *pView = (CViewWnd *)GetDlgItem(IDC_PREVIEW); // ConnectEvents(); if(pList->SetCurSel(0) != LB_ERR) { pList->GetText(0 ,(pList->m_cstrCurSelected)); pView->CreatePreview(); pView->DoPreview(); ConnectEvents(); } else { ConnectEvents(); } ret = TRUE; } catch (...) { TRACE_EXCEPTION("CTDialog::OnInitDialog") _clearfp(); } // RELEASE(pProp) // RELEASE(pProps) // RELEASE(m_pIApplication) // TODO: Add extra initialization here return ret; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CTDialog::OnClose() { // TODO: Add your message handler code here and/or call default if(m_dwEventConnection != 0) DisconectEvents(); CViewWnd *pView = (CViewWnd *)GetDlgItem(IDC_PREVIEW); pView->ClearAll(); m_pTool->m_bRunned = FALSE; if(m_pTool != NULL) { m_pTool->Release(); m_pTool = NULL; } if(m_pThisTool != NULL) { m_pThisTool->Release(); m_pThisTool = NULL; } CDialog::OnClose(); DestroyWindow(); } void CTDialog::OnSysCommand(UINT nID, LPARAM lParam ) { if (nID == SC_CLOSE) { if(m_dwEventConnection != 0) DisconectEvents(); CViewWnd *pView = (CViewWnd *)GetDlgItem(IDC_PREVIEW); pView->ClearAll(); m_pTool->m_bRunned = FALSE; if(m_pTool != NULL) { m_pTool->Release(); m_pTool = NULL; } if(m_pThisTool != NULL) { m_pThisTool->Release(); m_pThisTool = NULL; } } CDialog::OnSysCommand(nID, lParam ); } void CTDialog::OnModify() { // TODO: Add your control notification handler code here CWnd *pMainWnd = AfxGetMainWnd(); CTDialog1 *pdlg1 = new CTDialog1(m_pTool, pMainWnd); int i = pdlg1->DoModal(); } void CTDialog::OnCheck1() { // TODO: Add your control notification handler code here CViewWnd *pView = (CViewWnd *)GetDlgItem(IDC_PREVIEW); AFX_MANAGE_STATE(m_pTool->m_pTCState); Properties *pProps = NULL; Property *pProp = NULL; VARIANT varVal;//(0L); varVal.vt = VT_I2; CString cstrName("TileMode");//# Non-localizable string# BSTR bstrName = cstrName.AllocSysString(); VARIANT varItem; ::VariantInit(&varItem); varItem.vt = VT_BSTR; varItem.bstrVal = bstrName; try { if(pView->m_pPreviewDrawing != NULL) { HRESULT hRes = pView->m_pPreviewDrawing->get_Properties(&pProps); CHECK_HRESULT(hRes) hRes = pProps->get_Item(&varItem, &pProp); CHECK_HRESULT(hRes) pProp->get_Value(NULL, &varVal); if (varVal.iVal == 0) // cur drawing mode is paper space { varVal.iVal = 1; hRes = pProp->put_Value(NULL, &varVal); CHECK_HRESULT(hRes) } else // cur drawing mode is model space { varVal.iVal = 0; hRes = pProp->put_Value(NULL, &varVal); // switch the preview drawing to paper space CHECK_HRESULT(hRes) } pView->Invalidate(); hRes = pView->m_pPreviewView->ZoomToExtents(); CHECK_HRESULT(hRes) hRes = pView->m_pPreviewView->Refresh(); CHECK_HRESULT(hRes) ::VariantClear(&varItem); } } catch (...) { _clearfp(); TRACE_EXCEPTION("TDialog::OnCheck1") } if (pProp != NULL) { pProp->Release(); pProp = NULL; } if (pProps != NULL) { pProps->Release(); pProps = NULL; } } void CTDialog::DrawingBeforeClose(LPDISPATCH WhichDrawing, BOOL FAR* Cancel) { *Cancel = FALSE; Drawings *pDrs = NULL; long n = 0; try { HRESULT hRes = m_pIApplication->get_Drawings(&pDrs); CHECK_HRESULT(hRes) hRes = pDrs->get_Count(&n); CHECK_HRESULT(hRes) if (n == 2) { if(m_dwEventConnection != 0) DisconectEvents(); CViewWnd *m_wndView = (CViewWnd *)GetDlgItem(IDC_PREVIEW); m_wndView->ClearAll(); m_pTool->m_bRunned = FALSE; CDialog::OnClose(); DestroyWindow(); } } catch (...) { _clearfp(); TRACE_EXCEPTION("TDialog::DrawingBeforeClose") } if (pDrs != NULL) { pDrs->Release(); pDrs = NULL; } } void CTDialog::MouseDown(LPDISPATCH WhichDrawing, LPDISPATCH WhichView, LPDISPATCH WhichWindow, short Button, long Shift, long X, long Y, IMSI_BOOL* pbCancel) { *pbCancel = FALSE; } void CTDialog::MouseUp(LPDISPATCH WhichDrawing, LPDISPATCH WhichView, LPDISPATCH WhichWindow, short Button, long Shift, long X, long Y, IMSI_BOOL* pbCancel) { *pbCancel = FALSE; HRESULT hRes = E_FAIL; CMerge merge; IDrawing *pIDwgTrg = NULL; Graphics *pGrs = NULL; COleVariant varOptional(varMissing); CViewWnd *pView = (CViewWnd *)GetDlgItem(IDC_PREVIEW); AFX_MANAGE_STATE(m_pTool->m_pTCState); try { if(m_pDragGraphic != 0) { pIDwgTrg = (IDrawing*)WhichDrawing; pIDwgTrg->AddRef(); hRes = merge.InitA(pView->m_pPreviewDrawing, pIDwgTrg); CHECK_HRESULT(hRes) hRes = merge.RunA(); CHECK_HRESULT(hRes) hRes = pIDwgTrg->get_Graphics(&pGrs); // get current drawing graphic collection CHECK_HRESULT(hRes) hRes = pGrs->AddGraphic(m_pDragGraphic, varOptional, varOptional); CHECK_HRESULT(hRes) hRes = merge.CorrectGraphic(m_pDragGraphic); CHECK_HRESULT(hRes) hRes = m_pDragGraphic->Update(); CHECK_HRESULT(hRes) pIDwgTrg->Release(); pIDwgTrg = NULL; CPoint point; point.x = X; point.y = Y; m_pView = (View*) WhichView; m_pView->AddRef(); EndDrag(point); hRes = m_pView->Refresh(); CHECK_HRESULT(hRes) m_FirstClick = FALSE; } } catch (...) { _clearfp(); TRACE_EXCEPTION("TDialog::MouseUp") } if (m_pView != NULL) { m_pView->Release(); m_pView = NULL; } if (pGrs != NULL) { pGrs->Release(); pGrs = NULL; } } void CTDialog::MouseMove(LPDISPATCH WhichDrawing, LPDISPATCH WhichView, LPDISPATCH WhichWindow, long Shift, long X, long Y, IMSI_BOOL* pbCancel) { *pbCancel = FALSE; CPoint point; point.x = X; point.y = Y; Graphics* GrsTmp = NULL;; Graphics* pPreviewGrs = NULL;; IGraphic* Gr1 = NULL; long c = 0; IDrawing *pIDwgTrg = NULL; Graphics *pGrs = NULL; View *pViewCur = NULL; try { if (m_FirstClick == TRUE)/// && m_bDragging != FALSE) { if(m_pView != NULL) { m_pView->Release(); } m_pView = (View *)WhichView; m_pView->AddRef(); CViewWnd *pPreview = (CViewWnd *) (GetDlgItem(IDC_PREVIEW)); COleVariant varItem = (1L); HRESULT hRes = pPreview->m_pPreviewDrawing->get_Graphics(&pPreviewGrs); CHECK_HRESULT(hRes) #ifdef _DEBUG hRes = pPreviewGrs->get_Count(&c); CHECK_HRESULT(hRes) #endif varItem = 0L; hRes = pPreviewGrs->get_Item(varItem, &Gr1); CHECK_HRESULT(hRes) // check if the graphic that we drag is empty hRes = Gr1->get_Graphics(&GrsTmp); CHECK_HRESULT(hRes) long b = 0; hRes = GrsTmp->get_Count(&b); CHECK_HRESULT(hRes) if (b == 0) //if it is empty then return; { GrsTmp->Release(); GrsTmp = NULL; Gr1->Release(); Gr1 = NULL; pPreviewGrs->Release(); pPreviewGrs = NULL; m_FirstClick = TRUE; return; } hRes = Gr1->Duplicate(&m_pDragGraphic); CHECK_HRESULT(hRes) m_pDragGraphic->Release(); m_pDragGraphic = NULL; hRes = pPreviewGrs->get_Count(&c); CHECK_HRESULT(hRes) varItem = c -1L; hRes = pPreviewGrs->Remove(&varItem, &m_pDragGraphic); CHECK_HRESULT(hRes) m_FirstClick = FALSE; BeginDrag(point); } else { if (m_pDragGraphic != NULL && !m_bDragging)/// aalb && (nFlags & MK_LBUTTON)) { if (!BeginDrag(point)) { m_pDragGraphic->Release(); m_pDragGraphic = NULL; } } else if (m_bDragging) { pViewCur = (View *)WhichView; pViewCur->AddRef(); if (pViewCur != m_pView) // if view is changed then restart drag { m_pView = pViewCur; pViewCur->Release(); pViewCur = NULL; RestartDrag(point); } Drag(point); } } } catch (...) { TRACE_EXCEPTION("CTDialog::OnMouseMove") _clearfp(); } if(GrsTmp != NULL) { GrsTmp->Release(); GrsTmp = NULL; } if(Gr1 != NULL) { Gr1->Release(); Gr1 = NULL; } if(pPreviewGrs != NULL) { pPreviewGrs->Release(); pPreviewGrs = NULL; } } void CTDialog::ConnectEvents() { HRESULT hRes = S_OK; if (m_dwEventConnection != 0) { // AfxMessageBox("Already connected."); return; } m_pIApplication = NULL; try { hRes = m_pThisTool->get_Application(&m_pIApplication); CHECK_HRESULT(hRes) if (m_pIApplication == NULL) { // AfxMessageBox("Can't get a TurboCAD application!"); return; } IDispatch* pUnkEventSink = GetIDispatch(TRUE); UpdateData(TRUE); COleVariant var((long)m_dwEventMask); hRes = m_pIApplication->ConnectEvents(pUnkEventSink, &var, (long*)&m_dwEventConnection); if (FAILED(hRes)) { // AfxMessageBox("Connection not established."); return; } } catch (...) { TRACE_EXCEPTION("CTDialog::ConnectEvents") _clearfp(); } } void CTDialog::DisconectEvents() { if (m_pIApplication == NULL || m_dwEventConnection == 0) return; try { HRESULT hRes = m_pIApplication->DisconnectEvents(m_dwEventConnection); if (FAILED(hRes)) { // AfxMessageBox("Connection not broken."); return; } m_pIApplication->Release(); // possibility problem m_pIApplication = NULL; m_dwEventConnection = 0; } catch (...) { TRACE_EXCEPTION("CTDialog::DisconectEvents") _clearfp(); } } BOOL CTDialog::BeginDrag(const CPoint& point) { BOOL bRes = FALSE; HRESULT hRes = E_FAIL; BoundingBox* Box = NULL; IVertex* vMax = NULL; IVertex* vMin = NULL; double x, y, x1, y1; if (m_pView == NULL) return bRes; try { VariantClear(&m_dragOutline); SAFEARRAYBOUND bound; bound.cElements = 0; bound.lLbound = 0; m_dragOutline.vt = VT_ARRAY|VT_R8; m_dragOutline.parray = ::SafeArrayCreate(VT_R8, 1, &bound); hRes = m_pDragGraphic->CreateDragOutline(&m_dragOutline); CHECK_HRESULT(hRes); m_bDragging = TRUE; m_pDragGraphic->put_Visible(FALSE); VARIANT varState; varState.vt = VT_I4; varState.lVal = imsiDragBegin; hRes = m_pDragGraphic->CalcBoundingBox(NULL, &Box); CHECK_HRESULT(hRes) hRes = Box->get_Max(&vMax); CHECK_HRESULT(hRes) hRes = Box->get_Min(&vMin); CHECK_HRESULT(hRes) hRes = vMax->get_X(&x); CHECK_HRESULT(hRes) hRes = vMax->get_Y(&y); CHECK_HRESULT(hRes) hRes = vMin->get_X(&x1); CHECK_HRESULT(hRes) hRes = vMin->get_Y(&y1); CHECK_HRESULT(hRes) x = x1 + (x - x1)/2; y = y1 + (y - y1)/2; hRes = m_pView->ViewToScreen(x, y, &x1, &y1, NULL); CHECK_HRESULT(hRes) hRes = m_pView->DragOutline(&m_dragOutline, x1, y1, &varState); CHECK_HRESULT(hRes) varState.lVal = imsiDragContinue; hRes = m_pView->DragOutline(&m_dragOutline, point.x, point.y, &varState); CHECK_HRESULT(hRes) bRes = TRUE; } catch (...) { TRACE_EXCEPTION("CTDialog::BeginDrag") _clearfp(); } if (vMin != NULL) { vMin->Release(); vMin = NULL; } if (vMax != NULL) { vMax->Release(); vMax = NULL; } if (Box != NULL) { Box->Release(); Box = NULL; } return bRes; } BOOL CTDialog::Drag(const CPoint& point) { BOOL bRes = FALSE; if (m_pView == NULL) return bRes; try { VARIANT varState; varState.vt = VT_I4; varState.lVal = imsiDragContinue; HRESULT hRes = m_pView->DragOutline(&m_dragOutline, point.x, point.y, &varState); CHECK_HRESULT(hRes) bRes = TRUE; } catch (...) { TRACE_EXCEPTION("CTDialog::Drag") _clearfp(); } return bRes; } BOOL CTDialog::EndDrag(const CPoint& point) { BOOL bRes = FALSE; m_bDragging = FALSE; IMatrix *pMat = NULL; if (m_pView == NULL || m_pDragGraphic == NULL) return bRes; IDrawing *pIDwg = NULL; Properties *pProps = NULL; Property *pProp = NULL; try { VARIANT varState; varState.vt = VT_I4; varState.lVal = imsiDragEnd; HRESULT hRes = m_pView->DragOutline(&m_dragOutline, point.x, point.y, &varState); CHECK_HRESULT(hRes) VariantClear(&m_dragOutline); double dx, dy, dz; dx = dy = dz = 0; double dxWorld, dyWorld, dzWorld; dxWorld = dyWorld = dzWorld = 0; hRes = m_pView->ScreenToView(point.x, point.y, &dx, &dy); CHECK_HRESULT(hRes) dxWorld = dx; dyWorld = dy; VARIANT var; var.vt = VT_ERROR; var.scode = DISP_E_PARAMNOTFOUND; // ImsiSpaceModeType curMode; // will be available in TCW5.03 decoment this part to give correct position of inserted symbol in model space. // HRESULT hRes = S_OK; CString cstrName("TileMode");//# Non-localizable string# BSTR bstrName = cstrName.AllocSysString(); VARIANT varItem; ::VariantInit(&varItem); varItem.vt = VT_BSTR; varItem.bstrVal = bstrName; hRes = m_pView->get_Drawing(&pIDwg); CHECK_HRESULT(hRes) hRes = pIDwg->get_Properties(&pProps); CHECK_HRESULT(hRes) hRes = pProps->get_Item(&varItem, &pProp); CHECK_HRESULT(hRes) COleVariant varVal;//(0L); hRes = pProp->get_Value(NULL, &varVal); CHECK_HRESULT(hRes) if(varVal.lVal == 1) //ModelSpace { hRes = m_pView->ViewToWorld(dx, dy, dz, &dxWorld, &dyWorld, &dzWorld); CHECK_HRESULT(hRes) } hRes = m_pDragGraphic->MoveAbsolute(dxWorld, dyWorld, 0, &var, &var, &var, &pMat); CHECK_HRESULT(hRes) hRes = m_pDragGraphic->put_Visible(TRUE); CHECK_HRESULT(hRes) bRes = TRUE; } catch (...) { TRACE_EXCEPTION("CTDialog::EndDrag") _clearfp(); } if(pMat != NULL) { pMat->Release(); pMat = NULL; } if (m_pDragGraphic != NULL) { m_pDragGraphic->Release(); m_pDragGraphic = NULL; } if (pProp != NULL) { pProp->Release(); pProp = NULL; } if (pProps != NULL) { pProps->Release(); pProps = NULL; } if (pIDwg != NULL) { pIDwg->Release(); pIDwg = NULL; } return bRes; } BOOL CTDialog::RestartDrag(const CPoint& point) { try { m_bDragging = FALSE; VARIANT varState; varState.vt = VT_I4; varState.lVal = imsiDragEnd; HRESULT hRes = m_pView->DragOutline(&m_dragOutline, point.x, point.y, &varState); CHECK_HRESULT(hRes) VariantClear(&m_dragOutline); BeginDrag(point); } catch (...) { TRACE_EXCEPTION("CTDialog::RestartDrag") _clearfp(); } return TRUE; } void CTDialog::OnBrowse() { CToolList *pList = (CToolList *)GetDlgItem(IDC_LIST1); CViewWnd *pView = (CViewWnd *)GetDlgItem(IDC_PREVIEW); CEdit *pPath = (CEdit *) GetDlgItem(IDC_EDITPATH); CDirDialog* pDirDlg = new CDirDialog; //pDirDlg->m_strTitle = "Select directory contains tcw symbols. ";//# Localizable string# pDirDlg->m_strTitle.LoadString(IDS_STRING104); pPath->GetWindowText(pDirDlg->m_strSelDir); CString strtmp; pPath->GetWindowText(strtmp); int i = pDirDlg->DoBrowse (m_hWnd); if(i == 0) return; HCURSOR hOC = ::SetCursor(::LoadCursor(NULL,IDC_WAIT)); if (strtmp != pDirDlg->m_strPath) { pPath->SetWindowText ((LPCTSTR) pDirDlg->m_strPath); pView->ClearAll (); pView->Invalidate (); pList->RefreshFileList(pDirDlg->m_strPath); if(pList->SetCurSel(0) != LB_ERR) { pList->GetText(0 ,(pList->m_cstrCurSelected)); pView->CreatePreview(); pView->DoPreview(); } // else // { // pList->m_cstrCurSelected = ""; // } } ::SetCursor(hOC); }